/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package service.enumerations;

/**
 *
 * @author dchapman
 */
public enum ProcessCategory {
    BREWING(1),
    PRIMARY_TO_CRASH(2),
    CRASH_TO_LAGER(3),
    LAGER_VIA_FILTER(4),
    LAGER_VIA_FINE(5),
    LAGER_VIA_TRANSFER(6),
    PACKAGE(7);
    
    private final int category;

    ProcessCategory(final int category) {
        this.category = category;
    }

    public int getCategory() {
        return category;
    }

    public static ProcessCategory getCategory(final String category) {
        return getCategory(Integer.parseInt(category));
    }
    
    public static ProcessCategory getCategory(final int category) {
        switch (category) {
        case 1:
            return BREWING;
        case 2:
            return PRIMARY_TO_CRASH;
        case 3:
            return CRASH_TO_LAGER;
        case 4:
            return LAGER_VIA_FILTER;
        case 5:
            return LAGER_VIA_FINE;
        case 6:
            return LAGER_VIA_TRANSFER;
        case 7:
            return PACKAGE;
        default:
            throw new EnumConstantNotPresentException(ProcessCategory.class, String.valueOf(category));
        }
    }
    
    public static ProcessCategory getCategoryByName(final String str) {
        if(str.equals("BREWING")){
            return BREWING;
        } else if(str.equals("PRIMARY_TO_CRASH")){
            return PRIMARY_TO_CRASH;
        } else if(str.equals("CRASH_TO_LAGER")){
            return CRASH_TO_LAGER;
        } else if(str.equals("LAGER_VIA_FILTER")){
            return LAGER_VIA_FILTER;
        } else if(str.equals("LAGER_VIA_FINE")){
            return LAGER_VIA_FINE;
        } else if(str.equals("LAGER_VIA_TRANSFER")){
            return LAGER_VIA_TRANSFER;
        } else {
            return PACKAGE;
        }
    }
    
}
